package cn.biplam.setup.code.page;

import cn.biplam.common.client.DataFilter;
import cn.biplam.common.wrapper.ErrorMessage;
import cn.biplam.front.html.HtmlDiv;
import cn.biplam.front.html.base.HtmlWindow;
import cn.biplam.front.htmlscript.script.AjxScript;
import cn.biplam.setup.code.CodeManage;
import cn.biplam.setup.code.CodeManageBean;
import cn.biplam.setup.code.ExchangeCodeData.Code_Type;

/**
 * 页面代码管理
 * @author XiaoRuxing Sep 29, 20099:34:12 AM
 * @version 1.0
 */
public class PageCodeManage extends CodeManage {

	public PageCodeManage() {
		super("9103");
		dataOpt = new PageCodeData();
		bean = new CodeManageBean();
		this.codeType = "Page_Code";
	}

	/**
	 * 设置代码ID
	 */
	protected void setCodeId(){
		if(Code_Type.Page_Code.toString().equals(recordId)){
			this.codeId = null;
		}else{
			this.codeId = recordId;
		}
	}
	
	/**
	 * 添加代码操作
	 * 
	 * @return
	 * @throws ErrorMessage
	 */
	protected HtmlWindow _getAddOpt() throws ErrorMessage {
		DataFilter filter = new DataFilter();
		filter.putAll(params);
		filter.put(dataOpt.PRODUCT_ID, params.getByKey(dataOpt.PRODUCT_ID+"value"));
		String codeId = recordId;
		if (Code_Type.Page_Code.toString().equals(recordId)) {
			codeId = null;
		}
		filter.put(dataOpt.CODE_TYPE, codeId);
		dataOpt.AddCode(filter);
		HtmlWindow win = new HtmlDiv();
		win.bind(AjxScript.getA(cId, this.View_Next_Level,recordId));
		return win;
	}
}
